﻿#include "GlobalFiles.h"
#include "FITK_Kernel/FITKCore/FITKActionOperator.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"
#include "FITK_Kernel/FITKCore/FITKThreadPool.h"

Files* FilesWapper::new_Files()
{
    return new Files;
}
void FilesWapper::delete_Files(Files* F)
{
    if (F) delete F;
}
void FilesWapper::static_Files_ImportBDFFile(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionImportNastranBDF");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}
void FilesWapper::static_Files_ExportBDFFile(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionExportNastranBDF");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}
void FilesWapper::static_Files_ImportXMLFile(const QString& fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionImportVAOneXML");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_ExportXMLFile(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionExportVAOneXML");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_ImportGeoFile(const QString& fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionImportGeometry");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_ExportGeoFile(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionExportSTEPFile");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_ImportHDF5File(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionOpen");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_ImportCSVFile(const QString & fileName)
{
    //获取操作器
    auto oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionCSVResult");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_NewFile(const QString & fileName)
{
    //获取操作器
    Core::FITKActionOperator* oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionNew");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::static_Files_SaveFile(const QString & fileName)
{
    //获取操作器
    Core::FITKActionOperator* oper = FITKOPERREPO->getOperatorT<Core::FITKActionOperator>("actionSaveAs");
    if (oper == nullptr) return;
    //设置参数，与界面统一
    oper->setArgs("FileName", fileName);
    oper->execProfession();
    this->initSleep();
}

void FilesWapper::initSleep()
{
    //_sleep(100);
    //获取线程池
    Core::FITKThreadPool* pool = Core::FITKThreadPool::getInstance();
    if (pool == nullptr)return;
    //等待线程结束
    pool->wait();
}
 
 
